﻿<!DOCTYPE html>

<html class="x-admin-sm" xmlns:th="http://www.thymeleleaf.org">
<head th:insert="base">
    <meta charset="UTF-8">
    <title></title>
</head>
<link href="/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
<link href="/css/global.css" rel="stylesheet" />
<link href="/css/resource.css" rel="stylesheet" />
<script src="/js/front/global.js"></script>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="/back/user/welcome">首页</a>
            <a href="#">竞拍中心</a>
            <a>
              <cite>竞拍列表</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <div class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" id="goodName"  placeholder="请输入拍品名称" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-input-inline layui-show-xs-block">
                        <select id="goodType">
                        </select>
                    </div>
                        <div class="layui-input-inline layui-show-xs-block">
                            <select id="sortType">
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" readonly  autocomplete="off" placeholder="发布开始日期" id="createTimeStart">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input class="layui-input" readonly  autocomplete="off" placeholder="发布截止日期" id="createTimeEnd">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" id="formSearch"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </div>
                </div>
                <!--<div class="">-->
                    <div class="blog-container">
                        <div class="blog-main">
                            <div class="blog-main">
                                <div class="resource-main" id="auctionGoods">
                                </div>
                            </div>
                        </div>
                    </div>
                <!--</div>-->
            </div>
        </div>
    </div>
</div>

<div class="blog-mask animated layui-hide"></div>
<script th:inline="none">
    layui.use(['form','util','tool','laydate','enums','auctionUtil'], function(){
        var form = layui.form;
        var $ = layui.jquery;
        var form = layui.form;
        var util = layui.util;
        var tool = layui.tool;
        var enums = layui.enums;
        var laydate = layui.laydate;
        var baseUrl = "/back/auctionGood";
        var auctionUtil = layui.auctionUtil;
        init_form();
        init_auctionGoods(getQueryParams());

        //条件查询
        $('#formSearch').on('click', function(){
            init_auctionGoods(getQueryParams())
        });

        /**
         * 查询的参数
         * @returns {{}}
         */
        function getQueryParams() {
            return {
                auctionStatus:'2'
                ,goodName:$("#goodName").val().trim()
                ,goodType:$("#goodType").val().trim()
                ,sortType:$("#sortType").val().trim()
                ,createTimeStart:$("#createTimeStart").val().trim()
                ,createTimeEnd:$("#createTimeEnd").val().trim()
            }
        }
        /**
         * 初始化页面
         */
        function init_form() {
            auctionUtil.createGoodType('goodType',null,'请选择拍品类别');
            enums.createSelectByEnum('sortType','EnumSortType',null,null,'请选择排序方式');
            form.render();
            laydate.render({
                elem: '#createTimeStart'
                ,type: 'datetime'
            });
            laydate.render({
                elem: '#createTimeEnd'
                ,type: 'datetime'
            });
        }
        /**
         * 加载所有竞拍中的拍品信息
         */
        function init_auctionGoods(params) {
            $.ajax({
                url:baseUrl + '/getList'
                ,type:'post'
                ,data:params
                ,async:false
                ,dataType:'json'
                ,success:function(res){
                    //动态生成竞拍中的拍品信息
                    if(res.code == '0'){
                        $("#auctionGoods").empty();
                        for (var i = 0; i < res.data.length; i++) {
                            var selectHtml ="<div class=\"resource shadow\">\n" +
                                "                            <div class=\"resource-cover\">\n" +
                                "                                <img src=\""+res.data[i].goodImg+"\" alt=\""+res.data[i].goodName+"\" />\n" +
                                "                            </div>\n" +
                                "                            <h1 class=\"resource-title\"><a onclick=\"xadmin.open('拍品详情','/back/auctionGood/view?id="+res.data[i].id+"')\">"+res.data[i].goodName+"</a></h1>\n" +
                                "                            <p class=\"resource-abstract\">"+res.data[i].goodDesc+"</p>\n" +
                                "                            <div class=\"resource-info\">\n" +
                                "                                <span class=\"category\">竞价次数:"+res.data[i].bidNum+"</span>\n" +
                                "                                <span class=\"category\">最高竞价:"+res.data[i].maxPrice+"</span>\n" +
                                "                                <span class=\"author\">起拍价:"+res.data[i].startPrice+"</span>\n" +
                                "                                <div class=\"clear\"></div>\n" +
                                "                            </div>\n" +
                                "                            <div class=\"resource-footer\">\n" +
                                "                                <a class=\"layui-btn layui-btn-small layui-btn-primary\" onclick=\"xadmin.open('拍品详情','/back/auctionGood/view?id="+res.data[i].id+"')\">拍品详情</a>\n" +
                                "                            </div>\n" +
                                "             </div>";
                            $("#auctionGoods").append(selectHtml);
                        }
                    }else{
                        console.log("初始化拍品信息失败");
                    }
                }
                ,error:function(){
                    console.log("动态生成拍品信息异常");
                }
            });
            <!-- 清除浮动 -->
            $("#auctionGoods").append("<div class=\"clear\"></div>");
            form.render();//重新渲染
        }


    });
</script>
</body>
</html>